%% Author: 77
%% Created: 2011-7-10
%% Description: TODO: Add description to sequence
-module(sequence).
-author(kanghua ).  
-email(kanghua151@msn.com).  
-date("2011.07.06").  

-record(counter, {id, sequence}).

%%
%% Include files
%%

%%
%% Exported Functions
%%

-export([init/0]).
-export([get_next_sequence/1]).
%%
%% API Functions
%%
init() ->
  mnesia:start(),
  %mnesia:create_schema([node()]),
  mnesia:create_table(counter,  [{attributes, record_info(fields, counter)},
                                 {disc_copies, [node()]}]),
  mnesia:stop().
  
get_next_sequence(X) ->
	 mnesia:dirty_update_counter(counter,X, 1).

%get_next_sequence(_X) ->
%	Vmid = os:cmd("uuidgen") -- "\n\r",
%	Vmid.


%get_table_atom_name(Name) when is_list(Name) ->
%         list_to_atom(Name ++ ".seq");
%get_table_atom_name(Name) when is_atom(Name) ->
%         list_to_atom(atom_to_list(Name) ++ ".seq").

%%
%% Local Functions
%%

